package com.ncmem.up6.storage;

import com.ncmem.up6.PathTool;
import com.ncmem.up6.model.FileInf;

import java.io.ByteArrayOutputStream;

public class MinioBlockWriter extends FileBlockWriter{

    public MinioBlockWriter() {
        this.storage=StorageType.Minio;
    }

    /**
     * 生成UploadId
     */
    public String make(FileInf file)
    {
        String ext = PathTool.getExtention(file.pathSvr);
        byte[] buf = new byte[0];
        String fileID = MinioTool.CreateMultipartUpload(file.S3Key());
        return fileID;
    }

    public String write(FileInf file, ByteArrayOutputStream ostm)
    {
        byte[] data = ostm.toByteArray();
        return MinioTool.UploadPart(file.S3Key(), file.blockIndex, file.minio_id, data);
    }

}
